<?php
/**
 * 仓库产品公共模型，主要是用来获取 绑定了仓库的产品信息
 * @author shipanpan
 *
 */
class Application_Model_WarehouseProduct extends Model_Base {

	public function __construct() {
		$this->db = $this->db();
	}

	/**
	 * 是否是新品
	 * @param  [type]  $goodsSn   [description]
	 * @param  [type]  $warehouse [description]
	 * @return boolean 是新品返回true,否则返回false
	 */
	public function isNewProduct($goodsSn, $warehouse) {
		$where = $this->db->quoteInto("goods_sn=?", $goodsSn);
		$where .= " AND " . $this->db->quoteInto("warehouse=?", $warehouse);
		$warehouseProduct = $this->db->fetchRow('select is_new from p_warehouse_product where ' . $where);
		if ($warehouseProduct && $warehouseProduct['is_new'] == 1) {
			return true;
		}
		return false;
	}

	/**
	 * 是否清仓
	 * @param  [type]  $goodsSn   [description]
	 * @param  [type]  $warehouse [description]
	 * @return boolean 清仓返回true，否则返回false
	 */
	public function isClearance($goodsSn, $warehouse) {
		$where = $this->db->quoteInto("goods_sn=?", $goodsSn);
		$where .= " AND " . $this->db->quoteInto("warehouse=?", $warehouse);
		$warehouseProduct = $this->db->fetchRow('select * from p_warehouse_product where ' . $where);
		if ($warehouseProduct && $warehouseProduct['is_clearance'] == 1) {
			return true;
		}
		return false;
	}
}
